package study.springcloud.breaker.sentinel.client;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class UserClient {

    @SentinelResource(value = "get_user_info")
    public UserInfo getUserInfo(long timeout) {
        log.info("aaaaaaaaaaaaa");
        UserInfo info = new UserInfo();
        info.setUserId(10001L);
        info.setUserName("wzj");
        int a = 1 / 0;
        return info;
    }

    public UserInfo testGetUserInfo(long timeout, BlockException ex) {
        log.info("bbbbbbbbb");
        UserInfo info = new UserInfo();
        info.setUserId(10001L);
        info.setUserName("wzj_降级");
        return info;
    }

    @Data
    public static class UserInfo {
        private Long userId;
        private String userName;
    }
}
